home *** CD-ROM | disk | FTP | other *** search
- Path: engnews1.Eng.Sun.COM!taumet!clamage
- From: "Nathan Myers <ncm@cantrip.org>" <ncm@cantrip.org>
- Newsgroups: comp.std.c++
- Subject: Re: auto_ptr::is_owner()
- Date: 13 Apr 1996 23:17:16 GMT
- Organization: Best Internet Communications
- Approved: clamage@eng.sun.com (comp.std.c++)
- Message-ID: <316F533D.262C89BD@cantrip.org>
- References: <009A0A5CE1159CC0.49802F14@ittpub.nl> <gregorDpoGM2.Hw2@netcom.com>
- NNTP-Posting-Host: taumet.eng.sun.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Nntp-Posting-Host: ncm.vip.best.com
- X-Mailer: Mozilla 2.01 (X11; I; Linux 1.2.13 i386)
- Content-Length: 1022
- Originator: clamage@taumet
-
- Greg Colvin wrote:
-
- > In article <009A0A5CE1159CC0.49802F14@ittpub.nl> "Wil Evers" <wil@ittpub.nl>:
- > >What I definitely do not understand is why the new auto_ptr template
- > >doesn't even allow us to query if it is actually owning the object
- > >pointed to.
-
- > I found it very hard to contrive examples where is_owner() would
- > actually be useful.
-
- I agree with Greg here: any code that is intended to execute
- differently, depending on the value returned by putative member
- auto_ptr<>::is_owner(), is just bad code.
-
- I can imagine:
-
- auto_ptr<T> p1;
- auto_ptr<T> p2 = new T;
- if (...) {
- p1 = p2;
- }
- // what to do here?
-
- The answer is: it's your responsibility to keep track of ownership
- of pointers; if you can't do it manually, then automate it with
- reference counting or something. That's not what auto_ptr<> is for;
- its purpose is to make sure that the value "new T" gets destroyed.
- It does that job perfectly; don't ask it to do your job too.
-
- Nathan Myers
- ncm@cantrip.org http://www.cantrip.org/
-
-
- [ comp.std.c++ is moderated. To submit articles: try just posting with ]
- [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
- [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
- [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
- [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
-